/**
 * 
 */
package com.huarui.desktop.model;

import java.util.ArrayList;

/**
 * @author sunpeng
 * 
 */
public class ModuleScript {

	private ModuleScriptDesc desc;
	private ModuleScriptFunct functInit;
	private ModuleScriptFunct functCreate;
	private ArrayList<ModuleScriptFunct> functOthers = new ArrayList<ModuleScriptFunct>();
	private ModuleScript subModuleScript;
	
	public ModuleScriptDesc getDesc() {
		return desc;
	}

	public void setDesc(ModuleScriptDesc desc) {
		this.desc = desc;
	}

	public ModuleScriptFunct getFunctInit() {
		return functInit;
	}

	public void setFunctInit(ModuleScriptFunct functInit) {
		this.functInit = functInit;
	}

	public ModuleScriptFunct getFunctCreate() {
		return functCreate;
	}

	public ModuleScript getSubModuleScript() {
		return subModuleScript;
	}

	public void setSubModuleScript(ModuleScript subModuleScript) {
		this.subModuleScript = subModuleScript;
	}

	public void setFunctCreate(ModuleScriptFunct functCreate) {
		this.functCreate = functCreate;
	}

	public void addFunctOthers(ModuleScriptFunct function) {
		this.functOthers.add(function);
	}

	public ArrayList<ModuleScriptFunct> getFunctOthers() {
		return functOthers;
	}

	public String description() {
		StringBuilder builder = new StringBuilder();
		builder.append(this.desc.getWinClassName() + " = Ext.extend(Ext.app.Module, {");
		for (ModuleScriptFunct funct : functOthers) {
			builder.append("\n\n").append(funct.toString()).append(",");
		}
		builder.append("\n\n").append(functInit.toString()).append(",");
		builder.append("\n\n").append(functCreate.toString());
		if(this.subModuleScript!=null){
		builder.append("\n\n").append(this.subModuleScript.description());
		}
		builder.append("\n});\n");
		return builder.toString();
	}
	
	public String toString(){
		return description();
	}
}
